home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
-
- cParts *parts = 0;
-
- void cParts::make(int x, int y, int n)
- {
- ASSERT(!parts_list.is_empty());
-
- if (!low_detail_level)
- for (; n > 0; n--)
- {
- int rx = pmrnd(20), ry = pmrnd(20);
-
- new cParts(x + rx, y + ry, rnd(300), angle(rx, ry), parts_list.get_random());
- }
- }
-
- cParts::cParts(int _x, int _y, int v, fix angle, cProperties *_orig)
- : cGameObject(_orig)
- {
- // Set animation sequence
-
- set_sequence("MOVING", orig->params->get_bool("*LOOP_ANIMATION", TRUE));
-
- // Set position
-
- set_position(_x, _y);
- set_angular_speed(v, angle);
-
- // Put in list
-
- add_end((cList **)&parts);
-
- // Get scale
-
- max_scale = orig->params->get_fix("*MAX_SCALE", 0) * rnd(1000) / 1000;
- delta_scale = max_scale;
- scale_direction = 1;
- }
-
- cParts::~cParts()
- {
- }
-
- int cParts::control()
- {
- // Make trail
-
- make_trail();
-
- // Set scale
-
- fix new_scale = get_scale() + scale_direction * delta_scale * size_timer.delta();
-
- if (new_scale > max_scale + (fix)1)
- {
- new_scale = max_scale + (fix)1;
- scale_direction = -1;
- }
-
- else if (new_scale < (fix)1)
- {
- new_scale = 1;
- scale_direction = 0;
- }
-
- set_scale(new_scale);
-
- // Move
-
- cGameObject::control();
-
- bounce_on_boundaries();
-
- // Check if we were hit or when we go off screen
-
- return !animation_done() && !in_water();
- }
-